
from models import db

class Clockin(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80),nullable=False)
    status = db.Column(db.String(20),nullable=False)
    time = db.Column(db.DateTime,nullable=False)
    timetable_id = db.Column(db.Integer, db.ForeignKey('timetable.id'))   
    
    def __init__(self, dic):
        for key,value in dic.items():
            setattr(self, key, value)
    
    def __repr__(self):
        return '{}:{}:{}'.format(self.name,
                                self.start,
                                self.time)


tags = db.Table(
        'clockintags',
        db.Column('clockin_id',db.Integer, db.ForeignKey('clockin.id')),
        db.Column('tag_id',db.Integer, db.ForeignKey('tag.id'))
)
